﻿using Fozzy.Ontology;

namespace Fozzy.Gedcom
{
    /// <summary>
    /// One family group. 
    /// </summary>
    [XAlias("NAME")]
    [XLevel(1)]
    public class Name                                   : Fozzy.Name
    {
        #region States
        #endregion

        #region Properties            
            public string                               First_Name                      { get { return First                                            ; } }
            public string                               Middle_Name                     { get { return Second                                           ; } }
            public string                               Last_Name                       { get { return Third                                            ; } }
            public Name                                 Married_Name                    { get { return new Married_Name (Element)                       ; } }
            public Name                                 Nick_Name                       { get { return new Nick_Name    (Element)                       ; } }
            public Name                                 Suffix_Name                     { get { return new Suffix       (Element)                       ; } }
            //private Line                              Full_Name                       { get { return new Line(Alias, Serialise())                     ; } }
            public override Template                    Template                        { get { return new Prettier()                                   ; } }
        #endregion

        #region Constructeur
            public Name()
            {}
            //string name = GetValue(node, "NAME");
            public Name(_Element node)                       : base(node)
            {}
            public Name(Integer level, Fozzy.Name name)     : base(level.ToString())
            {}
            public Name(string parameter, Fozzy.Name name)  : base(parameter)
            {}
            public Name(Fozzy.Name name)                    : base(name.Instances)
            {}
            public Name(string parameter)                   : base(parameter)
            {}
        #endregion

            protected override void Prepare()
            {
                base.Prepare()                              ;
                Split(Statics.Slash)                        ;
            }

            //public override void Export()
            //{
            //    //    string firstMiddleNameSpace = (!string.IsNullOrEmpty(person.FirstName) && !string.IsNullOrEmpty(person.MiddleName)) ? " " : "";
            //    //    string value = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}/{3}/", person.FirstName, firstMiddleNameSpace, person.MiddleName, person.LastName);
            //    //    WriteLine(1, "NAME", value);
            //    base.Export();
            //    Full_Name   .Export()                       ;
            //    Nick_Name   .Export()                       ;
            //    Suffix_Name .Export()                       ;
            //    //    if (!string.IsNullOrEmpty(person.NickName))     WriteLine(2, "NICK", person.NickName)       ;
            //    //    if (!string.IsNullOrEmpty(person.Suffix))       WriteLine(2, "NPFX", person.Suffix)         ;
            //    //    if (!string.IsNullOrEmpty(person.MarriedName))  WriteLine(2, "_MARNM", person.MarriedName)  ;
                
            //}

            //private string Serialise()
            //{
            //    string firstMiddleNameSpace = (!string.IsNullOrEmpty(First_Name) && !string.IsNullOrEmpty(Middle_Name)) ? " " : ""              ;
            //    return string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}/{3}/", First_Name, firstMiddleNameSpace, Middle_Name, Last_Name)  ;
            //}

            //protected override void Parse(string parse)
            //{
            //    //string[] parts = name.Split('/');
            //    //if (parts.Length > 0) return parts[0].Trim()  ;
            //    //return string.Empty                           ;
            //}
    }
}
